﻿using Bigway.Common.Utils;
using SqlSugar;

namespace Bigway.Common.Models.DbModels;

public class BaseEntity
{
    [SugarColumn(IsPrimaryKey = true, IsNullable = false)]
    public string Id { get; set; } = CryptoUtils.GenerateShortUniqueId();

    [SugarColumn(IsNullable = false)] 
    public DateTime CreateTime { get; set; } = DateTime.UtcNow;

    private DateTime? _updateTime;

    [SugarColumn(IsNullable = false)]
    public DateTime UpdateTime
    {
        get => _updateTime ?? CreateTime;
        set => _updateTime = value;
    }
}